﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using QuizSilverlight.Web.App_Code;

namespace QuizSilverlight.Web.Administration
{
    public partial class SelectWinner : System.Web.UI.Page
    {
        QuizDataClassesDataContext quizzDC = new QuizDataClassesDataContext();
        protected void Page_Load(object sender, EventArgs e)
        {
            Random win = new Random();
            var winner = from selection in quizzDC.Participants
                         where selection.Id_Participant == Int32.Parse(win.ToString())
                         select selection;
            GridView1.DataSource = winner;
            GridView1.DataBind();

           

        }

        protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {  
            //collection des sites
            //la suppression se fait en cascade
            var delete_site = from site in quizzDC.WebSites
                          select site;
           

            quizzDC.WebSites.DeleteAllOnSubmit(delete_site);
                        
            quizzDC.SubmitChanges();
        }
    }
}